<template>
	<view>
		<view class="contact-head">
			<image class="portrait" :src="data.empImg || moren "></image>
			<text class="name">{{data.empName}}</text>
			<view class="module">
				<view class="call"> 
					<view class="icon" @click="onCall">
						<image src="../../../static/images/call.png" mode=""></image>
					</view> 
					<text class="name">拨打</text>
				</view>
				<!-- <view class="save" @click="onAddContact">
					<view class="icon">
						<image src="../../../static/images/add.png" mode=""></image>
					</view> 
					<text class="name">添加至本机</text>
				</view> -->
			</view>
		</view>
		<view class="list"> 
			<view class="list-item">
				<text class="title">部门</text>
				<text class="text">{{data.postName}}</text>
			</view>
			<view class="list-item">
				<text class="title">性别</text>
				<text class="text">{{data.employeeDetails.empSex}}</text>
			</view>
			<view class="list-item">
				<text class="title">手机</text>
				<text class="text">{{data.employeeDetails.empPhoneNumber}}</text>
			</view>
			<view class="list-item">
				<text class="title">座机</text>
				<text class="text">{{data.employeeDetails.empTelephone || '暂无'}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				moren: '../../../static/images/moren.png',
				data: {}
			}; 
		},
		onLoad(e) {
			console.log(e)
			this.data = JSON.parse(e.data)
		},
		onNavigationBarButtonTap(){ // 监听右上角按钮事件
			uni.navigateBack()
		}, 
		methods: {
			onCall() {
				const data = this.data.employeeDetails
				
				let { Mobile, landline } = { Mobile:  data.empPhoneNumber, landline: data.empTelephone }
				let tabList = landline? [`手机：${Mobile}`,`座机：${landline}`] : [`手机：${Mobile}`]
				let phone = null
				uni.showActionSheet({
					itemList: tabList,
					itemColor: "#999999", 
					success(res) {
						uni.makePhoneCall({
							phoneNumber:  res.tapIndex == 0? Mobile: landline
						})
					}
				})
			}
// 			onAddContact() {
// 				const data = this.data
// 				uni.addPhoneContact({
// 					nickName: `${data.postName} — ${data.empName}` ,
// 					firstName: data.empName,
// 					workPhoneNumber: data.employeeDetails.empPhoneNumber,
// 					mobilePhoneNumber:  data.employeeDetails.empPhoneNumber,
// 					title: data.postName,
// 					remark: '添加来源于物业管理app',
// 					success() { 
// 						uni.showToast({
// 							icon: "success",
// 							title: '保存联系人至本地成功！'
// 						})
// 					}
// 				})
// 			}
		}
	}
</script>

<style lang="scss">
	@import "../../../common/scss/common.scss";
	
	@import "mailDetails.scss"
</style>
